package ink.onei.system.service.impl;

import ink.onei.system.domain.Address;
import ink.onei.system.mapper.AddressMapper;
import ink.onei.system.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户地址Service业务层处理
 * 
 * @author nekotako
 * @date 2024-02-24
 */
@Service
public class AddressServiceImpl implements IAddressService  {
    @Autowired
    private AddressMapper addressMapper;

    /**
     * 查询用户地址
     * 
     * @param addrId 用户地址主键
     * @return 用户地址
     */
    @Override
    public Address selectAddressByAddrId(Long addrId) {
        return addressMapper.selectAddressByAddrId(addrId);
    }

    /**
     * 查询用户地址列表
     * 
     * @param address 用户地址
     * @return 用户地址
     */
    @Override
    public List<Address> selectAddressList(Address address) {
        return addressMapper.selectAddressList(address);
    }

    /**
     * 新增用户地址
     * 
     * @param address 用户地址
     * @return 结果
     */
    @Transactional
    @Override
    public int insertAddress(Address address) {
        return addressMapper.insertAddress(address);
    }

    /**
     * 修改用户地址
     * 
     * @param address 用户地址
     * @return 结果
     */
    @Transactional
    @Override
    public int updateAddress(Address address) {
        return addressMapper.updateAddress(address);
    }

    /**
     * 批量删除用户地址
     * 
     * @param addrIds 需要删除的用户地址主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteAddressByAddrIds(Long[] addrIds) {
        return addressMapper.deleteAddressByAddrIds(addrIds);
    }

    /**
     * 删除用户地址信息
     * 
     * @param addrId 用户地址主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteAddressByAddrId(Long addrId) {
        return addressMapper.deleteAddressByAddrId(addrId);
    }
}
